package vn.vos.model;

import com.google.gson.Gson;

public class JavaJSON {
	private Gson _gson;
	
	public JavaJSON() {
		_gson = new Gson();
	}
	
	public Gson get_gson() {
		return _gson;		
	}
	
	public void set_gson(Gson _gson) {
		this._gson = _gson;
	}

	public Object JSON2Object(String json, Class<?> classOfT) {		
		return _gson.fromJson(json, classOfT);
	}
	
	public String Object2JSON(Object obj) {		
		return _gson.toJson(obj);
	}
	
	public static void main(String args[]) {
		String str =  "{" +
					     " \"firstName\":\"John\", " +
					     " \"lastName\":\"John\", " +
					     " \"age\": 25" + 								   		 
					 "}";
		JavaJSON a = new JavaJSON();
		Object obj = a.JSON2Object(str, Test.class);
		
		System.out.println(obj.toString());
	}
}



